using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMVehicleGroupController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMVehicleGroup()
        {
            return cls.BindGridData("sp_TMVehicleGroup");
        }
        public DataTable BindGirdTMVehicleGroup_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMVehicleGroup_Detail_Edit", "@Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMVehicleGroup(clsTMVehicleGroupProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@VehicleGroup_Alias", data.VehicleGroup_Alias);
            cls.AddParameter("@VehicleGroup_Name", data.VehicleGroup_Name);
            cls.AddParameter("@VehicleGroup_Name_E", data.VehicleGroup_Name_E);
            cls.AddParameter("@VehicleGroup_Name_C", data.VehicleGroup_Name_C);
            cls.AddParameter("@VehicleGroup_Note", data.VehicleGroup_Note);
            cls.AddParameter("@MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMVehicleGroup_Insert");
            return true;
        }
        public bool UpdateTMVehicleGroup(clsTMVehicleGroupProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@VehicleGroup_ID", data.VehicleGroup_ID);
            cls.AddParameter("@VehicleGroup_Alias", data.VehicleGroup_Alias);
            cls.AddParameter("@VehicleGroup_Name", data.VehicleGroup_Name);
            cls.AddParameter("@VehicleGroup_Name_E", data.VehicleGroup_Name_E);
            cls.AddParameter("@VehicleGroup_Name_C", data.VehicleGroup_Name_C);
            cls.AddParameter("@VehicleGroup_Note", data.VehicleGroup_Note);
            cls.AddParameter("@MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMVehicleGroup_Update");
            return true;
        }
        public bool DeleteTMVehicleGroup(int id)
        {
            cls.Delete("sp_TMVehicleGroup_Delete", "@VehicleGroup_ID", id);
            return true;
        }
        public bool TMVehicleGroup_Check_Delete_TMVehicle(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMVehicleGroup_Check_Delete_TMVehicle", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMVehicleGroup_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}